<template>
  <div class="wrap">
    <img src="@img/loginBg.png" class="w-screen h-screen" alt />
    <div class="center">
      <h3>团务管理系统</h3>
      <div class="form">
        <div class="item">
          <img src="@img/loginPhone.png" alt />
          <input type="text" ref="account" v-model="account" placeholder="请输入账号" />
        </div>
        <div class="item">
          <img src="@img/pass.png" alt />
          <input v-model="password" type="password" ref="password" @focus="changeType" placeholder="请输入密码" />
        </div>
        <div class="bok">
          <p @click="login">登录</p>
          <!-- <p>注册</p>
          <a type="primary">忘记密码</a> -->
        </div>
      </div>
    </div>
  </div>
</template>
<style scoped lang="less">
.wrap {
  height: 100vh;
  position: relative;
  min-height: 720px;
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
  .bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    min-height: 720px;
  }
  .center {
    position: absolute;
    left: 50%;
    top: 10%;
    width: 44%;
    height: 580px;
    background: #fff;
    .loginLogo {
      width: 100px;
      margin-left: 80px;
      margin-top: 60px;
    }
    h3 {
      font-weight: bold;
      color: #719bef;
      font-size: 30px;
      margin-left: 100px;
      margin-top: 10px;
    }
    .form {
      margin-top: 80px;
      margin-left: 100px;
      .item {
        height: 60px;
        display: flex;
        align-items: center;
        border-bottom: 0.5px solid #719bef;
        width: 300px;
        margin-top: 20px;
        ::-webkit-input-placeholder {
          color: #719bef;
        }
        input {
          outline: none;
          background: transparent;
          border: none;
          display: block;
          margin-left: 15px;
          height: 100%;
          color: #719bef;
          font-size: 16px;
        }
        img {
          width: 20px;
        }
      }
      .bok {
        display: flex;
        align-items: center;
        margin-top: 50px;
        justify-content: space-between;
        align-items: center;
        align-content: center;
        width: 300px;
        p {
          margin-bottom: 0;
          width: 100px;
          height: 30px;
          border-radius: 30px;
          background: #719bef;
          text-align: center;
          line-height: 30px;
          color: #fff;
          cursor: pointer;
        }
        p:nth-of-type(2) {
          color: #719bef;
          border: 1px solid #719bef;
          background: #fff;
        }
      }
    }
  }
}
@media screen and (max-width: 1054px) {
  .bg {
    display: none;
  }
  .wrap .center {
    min-width: 400px;
    position: static;
    margin: 10% auto 0 auto;
  }
}
</style>

<script>
export default {
  data() {
    return {
      account: "admin",
      password: "1"
    };
  },
  methods: {
    login() {
      if (!this.account) {
        this.$notification.warn({ message: "请输入登陆账号" });
        this.$refs.account.focus()
        return false;
      }
      if (!this.password) {
        this.$notification.warn({ message: "请输入密码" });
        this.$refs.password.focus()
        return false;
      }
      this.$ajax({
        url: this.$api.common.login,
        data: {
          username: this.account,
          password: this.password
        },
        success: (result) => {
          this.$message.success('登录成功');
          sessionStorage.setItem('userInfo', JSON.stringify(result.user))
          sessionStorage.setItem('menuList', JSON.stringify(result.menuList))
          sessionStorage.setItem('apiList', JSON.stringify(result.apiList))
          sessionStorage.setItem('mlfastsessionid', result.mlfastsessionid)
          this.$router.push("/index");
        },
      });
    },
    changeType(e) {
      e.srcElement.type = "password";
    },
  }
};
</script>
